/*********************************************************************
 *                                                                   *
 *  Js Css Minifier ( JsCssMin )                                     *
 *  Author: Igor Kanshyn                                             *
 *  Copyright (c) 2009, Igor Kanshyn. All rights reserved.           *
 *                                                                   *
 *  JsCssMin is released under the Apache Software License.          *
 *  See LICENSE.txt for more details.                                *
 *                                                                   *
 *********************************************************************/

package org.grenader.jscssmin;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Test;

/**
 * <p>Product: JsCssMin ( JavaScript and CSS Minifier )<br>
 * Author: Igor Kanshyn (grenader).
 * </p>
 * Date: Apr 25, 2009
 */
public class ResourceUtilsTestCase {

    @Test
    public void testIsJavaScriptLine_false() {
        assertFalse(ResourceUtils.isJavaScriptLine("<html>"));
        assertFalse(ResourceUtils.isJavaScriptLine("<script e"));
        assertFalse(ResourceUtils.isJavaScriptLine("weew </script>"));
        assertFalse(ResourceUtils.isJavaScriptLine("<script src=\"flat-search-25.js\"></script>"));
        assertFalse(ResourceUtils.isJavaScriptLine("<script type=\"text/javascript\"></script>"));
        assertFalse(ResourceUtils.isJavaScriptLine("<script src\"flat-search-25.js\" type=\"text/javascript\"></script>"));
        assertFalse(ResourceUtils.isJavaScriptLine("<script src\"flat-search-25.js\" type=\"javascript\"></script>"));
    }

    @Test
    public void testIsJavaScriptLine_true() {
        assertTrue(ResourceUtils.isJavaScriptLine("<script src=\"flat-search-25.js\" type=\"text/javascript\"></script>"));
        assertTrue(ResourceUtils.isJavaScriptLine("<script  type=\"text/javascript\" src=\"flat-search-25.js\"></script>"));
        assertTrue(ResourceUtils.isJavaScriptLine("<script  type=\"text/javascript\" SRC=\"flat-search-25.js\"></script>"));
        assertTrue(ResourceUtils.isJavaScriptLine("<script  TYPE=\"text/javascript\" SRC=\"flat-search-25.js\"></script>"));
        assertTrue(ResourceUtils.isJavaScriptLine("<script  type=\"text/JAVASCRIPT\" SRC=\"flat-search-25.js\"></script>"));
        assertTrue(ResourceUtils.isJavaScriptLine("<script  type=\"Text/Javascript\" SRC=\"flat-search-25.js\"></script>"));
    }


    @Test
    public void testIsCSSLine_false() {
        assertFalse(ResourceUtils.isCSSLine("<html>"));
        assertFalse(ResourceUtils.isCSSLine("<link rel"));
        assertFalse(ResourceUtils.isCSSLine("<link  href=\"funct-37.css\"/>"));
        assertFalse(ResourceUtils.isCSSLine("<link rel=\"stylesheet\"/>"));
        assertFalse(ResourceUtils.isCSSLine("<link rel=\"stylesheet\" href=\"funct-37.css\">"));
        assertFalse(ResourceUtils.isCSSLine("<link rel=\"stylesheet\" href\"funct-37.css\"/>"));
        assertFalse(ResourceUtils.isCSSLine("<link rel\"stylesheet\" href\"funct-37.css\"/>"));
    }

    @Test
    public void testIsCSSLine_true() {
        assertTrue(ResourceUtils.isCSSLine("<link rel=\"stylesheet\" type=\"text/css\" href=\"funct-37.css\"/>"));
        assertTrue(ResourceUtils.isCSSLine("<link type=\"text/css\" rel=\"stylesheet\" href=\"funct-37.css\"/>"));
        assertTrue(ResourceUtils.isCSSLine("<link rel=\"stylesheet\" href=\"funct-37.css\" type=\"text/css\" />"));
        assertTrue(ResourceUtils.isCSSLine("<link rel=\"STYLESHEET\" type=\"text/css\" href=\"funct-37.css\"/>"));
        assertTrue(ResourceUtils.isCSSLine("<link type=\"text/css\" rel=\"stylesheet\" HREF=\"funct-37.css\"/>"));
        assertTrue(ResourceUtils.isCSSLine("<link REL=\"stylesheet\" href=\"funct-37.css\" TYPE=\"text/css\" />"));
    }


}
